/**
 * 
 */
package com.example.clienta.config;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


/**
 * @Author Firmye
 * @Date 2017年12月8日 下午9:53:10
 * 
 * @Description 1.自定义认证失败处理器
 */
@Component
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {

	/**
	 * @Author Firmye
	 * @Date 2017年12月8日 下午9:53:23
	 *
	 * @Description 
	 */
	@Override
	public void commence(HttpServletRequest request, HttpServletResponse response,
			AuthenticationException authException) throws IOException, ServletException {
		response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
	}

}
